package com.katze.ssh.sftp;

import org.apache.sshd.sftp.client.SftpClient;

import java.io.Serializable;
import java.nio.file.attribute.AclEntry;
import java.util.List;

public class Attributes implements Serializable {
    private int type = 5;
    private int perms;
    private String owner;
    private String group;
    private Long accessTime;
    private Long createTime;
    private Long modifyTime;
    private List<AclEntry> acl;

    public Attributes (SftpClient.Attributes attributes) {
        this.type = attributes.getType();
        this.perms = attributes.getPermissions();
        this.owner = attributes.getOwner();
        this.group = attributes.getGroup();
        this.accessTime = attributes.getAccessTime() != null? attributes.getAccessTime().toMillis():null;
        this.createTime = attributes.getCreateTime() != null? attributes.getCreateTime().toMillis():null;
        this.modifyTime = attributes.getModifyTime() != null? attributes.getModifyTime().toMillis():null;
        this.acl = attributes.getAcl();
    }

    public int getType() {
        return type;
    }

    public int getPerms() {
        return perms;
    }

    public String getOwner() {
        return owner;
    }

    public String getGroup() {
        return group;
    }

    public Long getAccessTime() {
        return accessTime;
    }

    public Long getCreateTime() {
        return createTime;
    }

    public Long getModifyTime() {
        return modifyTime;
    }

    public List<AclEntry> getAcl() {
        return acl;
    }
}
